package com.dlnu.shoping.shopping.controller;

import com.dlnu.shoping.shopping.common.Result;
import com.dlnu.shoping.shopping.service.IAdService;
import com.dlnu.shoping.shopping.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

//    显示个人信息
    @RequestMapping("/search")
    public Result search(@RequestParam String userId) {
        return userService.search(userId);
    }
//    注册
    @RequestMapping("/register")
    public Result register(@RequestParam String name,@RequestParam String nickname,
                           @RequestParam String tel,@RequestParam String password) {
        return userService.register(name, nickname, tel, password);
    }

//    登录
    @RequestMapping("/login")
    public Result login(@RequestParam String name,
                        @RequestParam String password) {
        return userService.login(name, password);
    }

//    注销用户
    @RequestMapping("delUser")
    public Result delUser(@RequestParam Integer useId){
        return userService.delUser(useId);
    }

//    修改昵称
    @RequestMapping("alterUser")
    public Result alterUser(@RequestParam Integer userId,@RequestParam String nickname,
                            @RequestParam String password) {
        return userService.alterUser(userId,nickname, password);
    }
}
